package com.github.bluzwang.fluxsupport;

import de.greenrobot.event.Subscribe;
import de.greenrobot.event.ThreadMode;

/**
 * Created by lgvalle on 02/08/15.
 */
public abstract class Store {

    final private Dispatcher dispatcher;

    public Store(Dispatcher dispatcher) {
        this.dispatcher = dispatcher;
    }

    @Subscribe(threadMode = ThreadMode.MainThread)
    public void onReceiveActionRequest(Action action) {
        onRequestAction(action);
    }

    protected abstract void onRequestAction(Action action);

    protected Dispatcher.ResponseBuilder responseToUiWithType(String type) {
        return dispatcher.postResponseToUIWithType(type);
    }
}
